#include <iostream>
#include <unistd.h>
#include <pthread.h>
#include <cstdio>
#include <cstring>
void *rent(void *arg) // arg->"hello"
{
    std::string name = static_cast<const char *>(arg);
    while (true)
    {
        std::cout << name << "我是一个新进程" << std::endl;
        sleep(1);
    }
    return 0;
}
int main()
{
    pthread_t pt;
    int ret = pthread_create(&pt, nullptr, rent, (void *)"hello");
    if (ret != 0)
    {
        std::cout << "pthread_create error:" << strerror(ret) << std::endl;
        return 1;
    }
    while (true)
    {
        std::cout << "main 线程" << std::endl;
        sleep(1);
    }

    return 0;
}

